package cn.isjinhao.se.script.generator;

import cn.isjinhao.se.structure.impl.Table;
import cn.isjinhao.se.script.FileWrapper;
import cn.isjinhao.se.script.SqlTemplate;
import cn.isjinhao.se.script.parameter.ParameterReader;

import java.util.List;
import java.util.function.Function;

/**
 * @Author ISJINHAO
 * @Date 2021/6/30 14:24
 */
public abstract class AbstractScriptGenerator implements ScriptGenerator {

    protected ParameterReader parameterReader;

    public AbstractScriptGenerator(ParameterReader parameterReader) {
        this.parameterReader = parameterReader;
    }

    @Override
    public List<String> generateSqlScript(FileWrapper file, SqlTemplate scriptSql, Function<String, String> columnMapping) {
        Table table = extractParameterFromFile(file);
        return generateSqlScript(table, scriptSql, columnMapping);
    }

    protected abstract Table extractParameterFromFile(FileWrapper file);

    @Override
    public List<String> generateSqlScript(Table table, SqlTemplate scriptSql, Function<String, String> columnMapping) {
        return null;
    }


    @Override
    public List<String> generateSqlScript(FileWrapper file, Class<?> clazz, Function<String, String> propertyMapping) {
        return null;
    }

}
